package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlOfcperbase;
import com.ruoyi.sl.service.ISlOfcperbaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政绩效维护Controller
 * 
 * @author ruoyi
 * @date 2024-07-03
 */
@RestController
@RequestMapping("/sl/ofcperbase")
public class SlOfcperbaseController extends BaseController
{
    @Autowired
    private ISlOfcperbaseService slOfcperbaseService;

    /**
     * 查询行政绩效维护列表
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcperbase:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlOfcperbase slOfcperbase)
    {
        startPage();
        List<SlOfcperbase> list = slOfcperbaseService.selectUserSlOfcperbaseList(slOfcperbase);
        return getDataTable(list);
    }

    /**
     * 导出行政绩效维护列表
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcperbase:export')")
    @Log(title = "行政绩效维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlOfcperbase slOfcperbase)
    {
        List<SlOfcperbase> list = slOfcperbaseService.selectSlOfcperbaseList(slOfcperbase);
        ExcelUtil<SlOfcperbase> util = new ExcelUtil<SlOfcperbase>(SlOfcperbase.class);
        util.exportExcel(response, list, "行政绩效维护数据");
    }

    /**
     * 获取行政绩效维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcperbase:query')")
    @GetMapping(value = "/{userName}")
    public AjaxResult getInfo(@PathVariable("userName") String userName)
    {
        return success(slOfcperbaseService.selectSlOfcperbaseByUerName(userName));
    }

    /**
     * 新增行政绩效维护
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcperbase:add')")
    @Log(title = "行政绩效维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlOfcperbase slOfcperbase)
    {
        return toAjax(slOfcperbaseService.insertSlOfcperbase(slOfcperbase));
    }

    /**
     * 修改行政绩效维护
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcperbase:edit')")
    @Log(title = "行政绩效维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlOfcperbase slOfcperbase)
    {
        return toAjax(slOfcperbaseService.updateSlOfcperbase(slOfcperbase));
    }

    /**
     * 删除行政绩效维护
     */
    @PreAuthorize("@ss.hasPermi('sl:ofcperbase:remove')")
    @Log(title = "行政绩效维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ofcperbaseIds}")
    public AjaxResult remove(@PathVariable Long[] ofcperbaseIds)
    {
        return toAjax(slOfcperbaseService.deleteSlOfcperbaseByOfcperbaseIds(ofcperbaseIds));
    }
}
